﻿using System;
using System.Data;
using System.Configuration;
using System.Collections;
using System.Web;
using System.Web.Security;
using System.Web.UI;
using System.Web.UI.WebControls;
using System.Web.UI.WebControls.WebParts;
using System.Web.UI.HtmlControls;
using DrawChartImage;
using System.Drawing;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using Maticsoft.DBUtility;
using MySql.Data.MySqlClient;
using EnvironmentManagerSystem.MODE;
using System.Xml.Linq;
using EnvironmentManagerSystem.BLL;
using AjaxPro;
using System.Data.SqlClient;
using EnvironmentManagerSystem.Utility;

namespace EnvironmentManagerSystem.A
{
    public partial class ShouLiRens : System.Web.UI.Page
    {
        protected void Page_Load(object sender, EventArgs e)
        {
            if (!IsPostBack)
            {
                string tb1 = Request.QueryString["HeSuanRen1"];
                //NEW出柱形图片的对象
                ChartImage chartImage = new ChartImage();
                //设置图片的属性
                chartImage.ImageAtt.CaptionColor = Color.Blue;
                chartImage.ImageAtt.BorderDistance = 5;
                chartImage.ImageAtt.CaptionFont = new Font("宋体", 15);
                chartImage.ImageAtt.CPlace = CaptionPlace.Left;
                chartImage.ImageAtt.Caption = "受理人(统计)";
                chartImage.ImageAtt.LeftGraduationValue = 5;
                //chartImage.ImageAtt.Height =Convert.ToInt32(Session["ceshi"]);
                //设置图片中柱形的个数
                int ShouLiShu = Convert.ToInt32(BLL.HuanPingService.GetCount("SELECT COUNT(*) FROM tbs001_user WHERE RoleId LIKE '%受理人%'"));
                chartImage.ChartCount = ShouLiShu - 1;
                chartImage.ChartItems.Add(new Chart());
                #region MyRegion
                string strSql = string.Format("SELECT ID,UserName FROM tbs001_user WHERE tbs001_user.RoleId LIKE '%受理人%'");
                DataTable dt = DbHelperMySQL.Query(strSql).Tables[0];
                if (dt.Rows.Count == 0)
                    return;
                int ID = 0;//地区ID
                string UserName = "";//受理人名称
                int a = 0;//底部文字用
                foreach (DataRow dr in dt.Rows)
                {
                    for (int i = a; i < i + 1; i++)
                    {
                        ID = Convert.ToInt32(dr[0]);
                        UserName = dr[1].ToString();
                        int ShouLiGeShu = 0;
                        string strPJ = "";
                        if (tb1 == "请选择")
                            ShouLiGeShu = Convert.ToInt32(BLL.HuanPingService.GetCount("SELECT COUNT(*) FROM tbs001_developprojectbasicinfo WHERE xiangmushouliren='" + UserName + "'"));
                        else
                        {
                            strPJ += " AND hesuanren like '%" + tb1 + "%'";
                            ShouLiGeShu = Convert.ToInt32(BLL.HuanPingService.GetCount("SELECT COUNT(*) FROM tbs001_developprojectbasicinfo WHERE xiangmushouliren='" + UserName + "' AND 1=1 " + strPJ + " "));
                        }
                        //设置底部文字
                        chartImage.ChartItems[i].BottomText = UserName;
                        //设置柱形的标题文字
                        chartImage.ChartItems[i].Caption = ShouLiGeShu.ToString();
                        //设置柱形的高度
                        chartImage.ChartItems[i].Height = ShouLiGeShu * 5;
                        //Session["ceshi"] = ShouLiGeShu * 5 + 10;
                        //设置柱形的颜色
                        chartImage.ChartItems[i].SetChartColor(Color.White, Color.SeaGreen);
                        a = i + 1;
                        break;
                    }
                }
                #endregion
                //获得图片
                Bitmap bmp = chartImage.GetImage();
                Response.ContentType = "Image/jpeg";
                bmp.Save(Response.OutputStream, System.Drawing.Imaging.ImageFormat.Jpeg);
                Response.End();
            }
        }
    }
}